home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-13
/
hexedit.zip
/
XE.DOC
< prev
next >
Wrap
Text File
|
1991-11-11
|
28KB
|
627 lines
≡■≡ heXEdit ≡■≡
Version 3.0
11-11-91
Robert Stuntz
1747 Crystal Lane #610
Mt. Prospect, IL. 60056
GEnie : R.STUNTZ
DISCLAIMER
THIS SOFTWARE AND MANUAL ARE DISTRIBUTED "AS IS" AND WITHOUT
WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS
HARDWARE AND SOFTWARE ENVIRONMENTS INTO WHICH THIS PROGRAM MAY BE
PUT, NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED AND
ALL LIABILITY IN THE USE AND AFFECTS OF THIS PROGRAM SHALL REST
WITH THE USER.
THIS PROGRAM HAS THE ABILITY TO ALTER YOUR FILES! YOU ARE
RESPONSIBLE! (Sorry, but I have to warn you ...)
≡■≡ Introduction
heXEdit (XE) is a program that will allow you to
display and/or edit any file. It has few and simple commands
but serves my purposes perfectly. I wrote this program because
I became frustrated with a couple of other commercial programs.
They either had some annoying peculiarities or required too
much thought on my part just to search for and change a couple
of bytes.
heXEdit was written using Turbo Pascal v6.0, although
it doesn't use any of Borland's object libraries. It does
however write directly to the screen for speed when scrolling
thru the file. If you're using a CGA monitor you may see some
'snow' as I don't check for the vertical retrace period to
write to the screen.
heXEdit will keep no more than 1760 bytes of the file
in memory at a time, as I didn't feel like messing with a
variable amount of memory available. heXEdit requires about
106k bytes of free memory in order to execute.
≡■≡ Using heXEdit
To start heXEdit, enter
XE [drive | filename]
The drive designator and filename are optional on the
command line. If only a drive letter is specified XE will
change your current directory to that drive and show you the
files from the root directory of that drive. If a file is
specified XE will try to load that file, if not, the Loadfile
box will appear with a list of files in the current directory.
When heXEdit starts it looks for a configuration file
that defines the colors to be used. The name of the file is
'XE.CFG'. XE first looks in the current directory for the file.
If it doesn't find it there it checks the environment for a
variable named 'XE' and looks in the path specified by that
variable. (See your DOS manual for an explanation of
environment variables). If XE doesn't find it there it then
looks in the directory that XE.EXE is in.
The environment variable 'XE' can be set by using the
DOS SET command. You should include the full path, just so
there is no confusion as to what drive the file is on. For
example :
SET XE=C:\UTIL\
Also, the last back-slash character should be included as I
just append the filename to the path you specify. If you do
use an environment variable but XE can't find the file there,
it will look in the same directory that XE.EXE is in. If you
don't use the configuration file in the first place, XE will
use a default set of colors.
With the Loadfile box you can use the Up/Down arrow
keys, PgUp/PgDn and the Home/End keys to move the highlight bar
to the file you want to load. The Up/Down arrow keys will
move the bar one file at a time. PgUp/PgDn move the bar a page
at a time, and Home/End will move the bar to the beginning/end
of the list of files.
With the highlight bar over the file you want to load,
just hit <ENTER> to load the file.
While using the Loadfile box, you may encounter an
error, for one reason or another. Generally speaking, you will
be given one, some or all of the options below :
Option 1 - (A)bort : if you press 'A' XE will abort the
operation.
Option 2 - (R)etry : press 'R' to retry the operation. (Maybe
the drive door was opened before you hit <ENTER> to load the
file.)
Option 3 - (Q)uit XE : press 'Q' to quit XE and return to the
DOS prompt (or wherever it was that you came from).
Option 4 - Any other key : if you hit any other key than the
ones described above you will be returned to the Loadfile box.
While in the Loadfile box, hitting <ESC> will exit the
Loadfile box and either 1) return you to the last file you were
editing, or if no file was previously loaded 2) exit XE altogether.
One last feature of the Loadfile box is that you can change
the attributes of a file simply by hitting F5-F8 (providing the
file is available; i.e., the disk is in the drive etc.) Move
the highlight bar to file you want to work with and then simply
hit one of the following, depending on what you want to do.
F5 - toggles the Archive bit
F6 - toggles the System bit
F7 - toggles the Hidden bit
F8 - toggles the Read_Only bit
If the attribute change was successful you will hear a high
pitch tone otherwise you will hear a lower tone indicating that
the attribute could not be changed for one reason or another.
You should also see the attribute change in the Loadfile box.
*** Note *** Be sure you know what affect changing an attribute
will have on your system. Some programs act on the attributes
of a file or may even require certain attributes to be set.
Once the file is loaded you will see the main display.
At the top is the name of the file loaded. On the left side of the
display are numbers (in hexadecimal,decimal or octal) indicating
the offset into the file. In the middle are 22 rows of 16 bytes
each which are the file's contents. On the right, the ASCII
character for each byte in that row. In the ASCII portion of the
display, any characters past the EOF are shown as a '.' (#249).
On the bottom is a status word indicating your current operation,
a three letter abbrev indicating whether the offset display is in
'hex'adecimal, 'dec'imal, or 'oct'al, the percentage into the file
from the top line, and the size of the file in decimal.
≡■≡ Commands
Following is a list of commands once you are in XE and then a
brief explanation of each :
F1- Help
A - ASCII table
B - Base conversion (decimal-hexadecimal-binary)
C - Change colors
D - Change offset display to Decimal
E - Edit the file
G - Goto offset
H - Change offset display to Hexadecimal
L - Bring up the Loadfile box
M - Push position on marker stack
N - Search again (using the last used search string)
O - Change offset display to Octal
R - Retrieve position from marker stack
S - Search (for text or a byte string)
Z - Clear all entries from marker stack
Up/Down arrow keys - scroll up and down one line at a time
PgDn/PgUp - move up/down one page at a time
Home - move the beginning of the file
End - move to the end of the file
ESC/Alt+X - quit XE
■-- F1: Get help.
Help commands :
- F1 : Help on Help
- F2 : An index (keywords) for items in the help file
- F3 : Goto the previous screen
- F5 : Zoom/Unzoom the help screen
- Enter : Get help on a highlighted keyword
- ESC : Exits help
- Tab / Shft+Tab : Highlight the next/previous visible
keyword
- Arrow keys : Scroll the help screen contents left,
right, up and down
- Page Up/Down : Move up and down a page at a time
- Home/End : Goto the beginning/end of the help info for
the current item
In the upper left corner of the help screen (in the
border), you may see a number and possibly one of three
arrow characters.
The number is the left column, of the help info, you
are at. If you are at column one, it will not be
displayed.
The arrow characters indicate if there is more info
either above or below (or both) of your position.
A couple of notes on the help file.
1. heXEdit expects the help file (XE.HLP) to be in the
directory that XE.EXE is in. If it is not, you will
get an error message when you invoke help.
2. If you modify the help file, make sure your keywords
are capitalized and start in column one. It will
probably be easier to just look at the help file that
came with heXEdit to see how it's done.
3. There is a limit of 75 lines of information per
keyword.
4. Keyword information begins with it's keyword and
ends with a slash (#47).
5. To create a keyword in a help screen, precede the
keyword with a tilde (#126) and end it with a
back-quote (#96).
■-- A : This displays an ASCII chart.
ASCII chart commands :
- Left arrow key : go back 16 characters
- Right arrow key : go forward 16 characters
- PageUp : go back 128 characters
- PageDown : go forward 128 characters
- D : display numbers in decimal
- H : display numbers in hexadecimal
- ESC or Enter : exits ASCII chart
■-- B : Convert a number from either decimal, hexadecimal or
binary to the other two.
Base convert commands :
- Up/Down arrow keys : select the base of the input
number
- Enter : convert the number
- ESC : exit the base convert routine
Using the arrow keys, move the highlight bar to the
base of the input number and then either 1) hit Enter
and enter the number or 2) just start typing the
number. After the number has been converted, hit any
key to select the base for another conversion or hit
ESC to exit.
When you enter the number, I only check for validity
with the first character. If you try to convert an
invalid number an error message will be displayed. The
largest number that can be accurately converted is a 32
bit number. It has a very simple input routine, so
don't be surprised if you can enter an invalid number.
The conversion will be incorrect of course. I leave
it mostly up to you to enter a valid number.
■-- C : This command will allow you to change the color of just
about anything. Of course, if you're using a monochrome
monitor this command will do nothing. You can also save
a color configuration file if you like, so that XE will
startup with the colors you like.
I didn't do anything fancy here. Simply select the area
you want to change the color in by hitting a letter 'A'
thru 'W' (with the exception of 'S'), or '1-7'. Then
enter the number corresponding to the color you want.
Color change commands:
- F1 : get help
- A-W, 1-7 : select the area you want to change
(except 'S')
- ESC/Enter : exit the color change screen
- S : save a configuration file with the currently
selected colors
This command will save a file named 'XE.CFG'
that defines the colors for XE to use. The file
is saved in the same place it was found. If
this is the first time this file has existed,
it will be saved in the current directory.
This configuration file is not compatible with
previous versions. You will need to delete the
previous version .CFG file or you will get a
run-time error.
If you want the default colors back, simply delete the
configuration file and the next time you start XE
you'll have the default colors.
■-- D : Change the offset display to base 10, decimal.
■-- E : Begin editing the file at the current position. If the
file is a READ ONLY file, a short message to that
affect will appear and you will be returned to the view
mode. Of course, you could just hit 'L' to bring up the
Loadfile box and change the READ ONLY attribute of the
file with F8. And then go back and edit. But, it might
be READ ONLY for a reason ...
Edit commands :
- F1 : get help
- Alt+A : displays the ASCII chart
same thing as 'A' when just viewing
- Alt+B : base number conversion
same thing as 'B' when just viewing
- BackSpace/Left arrow key : move cursor left 1 byte
- Right arrow key : move cursor right 1 byte
- PageUp : move cursor to first line on page
- PageDown : move cursor to last line on page
- Home : move cursor to beginning of line
- End : move cursor to end of line
- TAB : toggle cursor position between the hexadecimal
display and the ASCII display of the file. The
above editing commands will move the cursor within
the area the cursor is in. You can edit the
file making changes in both areas at the same
time, if so desired.
- ESC/Enter : quit editing. If you made changes you
will be prompted to save the changes or not. Hit
'Y' to save the changes or 'N' to lose the changes.
Only the portion of the file that is in memory is
actually saved. So don't worry about waiting
for a long save if you are editing a large file.
You are then returned to the View mode.
To change a value when in the hexadecimal portion, just
type in it's new value. The background of the character
will change, indicating which bytes have been changed.
Valid values are '00' - 'FF'. Obviously, hitting a key
like 'P' will do nothing because 'P' is not a valid
hexadecimal character. A special note, once you change
the left half of the byte, you must continue and change
the right half also.
To change a value when in the ASCII portion of the
display, simply hit the key of the new value. Or,
hold down the ALT key while typing the ASCII code
of the character you want, then release the ALT
key. Using the ALT key in this area, you can
enter a value from 32-255. Again, the background will
change indicating a change.
Note - When in edit mode you will be able to change the
characters after the EOF. It will look like you are
changing the file but in reality nothing will be
changed. You cannot increase the size of the file,
only change what already exists. (A small price
to pay for making the coding easier on me!)
■-- G : Goto an offset in the file.
You are prompted for an offset to go to. You can enter
either a decimal number or a hexadecimal number. If you
hit ESC while entering a number you will be placed back
in the View mode with no repositioning taking place.
The BACKSPACE key can be used to edit your entry. If
you enter an offset that is beyond the End-Of-File
(or < 0) you will be prompted again for a number.
To enter a decimal number just type in the number, no
commas, and hit ENTER.
To enter a hexadecimal number, type a '$' as the first
character and then continue entering the hex number.
Also, if at anytime while entering a number, you enter
an 'A' through 'F' a '$' will be inserted into your
number at the beginning and your entry will be taken as
a hexadecimal number. For example:
Keystroke Screen
3 3
5 35
1 351
E $351E
etc ...
■-- H : Change the offset display to base 16, hexadecimal.
■-- L : Load a new file. You will enter the Loadfile box in
order to select a new file (as described earlier in
this document under ≡■≡ Using heXEdit).
Since you can't leave the edit mode without either
saving any changes or losing changes, you needn't worry
about saving the current file before loading a new one.
■-- M : Push position on marker stack.
Your current position in the file can be saved with
this command and then be retrieved later on.
Your position is saved on a stack. If the stack is full
the oldest position will be deleted and the rest of the
entries will move down the stack to make room for the
new entry. The maximum number of positions you can save
is 100. Also, when your position is saved, it's location
on the stack is reported to you so you can see how full
the marker stack is.
This command can also be used while searching. If the
search string is found, you can hit 'M' to save that
position on the marker stack and then continue searching.
■-- N : Search again using the last used search string. If
there is no previous search string, you will be
prompted, as if you hit 'S', to enter a search string.
■-- O : Change the offset display to base 8, octal.
■-- R : Goto (retrieve) position using the top marker stack
entry.
While viewing the file, if you hit this command you
will be moved to the location specified by the top
marker stack entry. Once you have been moved to the new
location, the entry you retrieved will be deleted
from the marker stack. If there are no markers on the
stack, then nothing will happen.
■-- S : Search the file for a byte or text sequence.
You will be prompted for the type of search (B)yte or
(T)ext.
For a byte sequence, enter the bytes in hexadecimal
notation then hit Enter. As with editing, you must
enter a complete byte, for the search to work
correctly, although I don't check for that here. You
can use the backspace key to go back and make
corrections. The maximum length for a byte sequence is
9 bytes. I think that is plenty long enough, even 4
bytes would probably be enough to find what you're
looking for. For example, you might see this prompt :
Enter search bytes :
Now you would just hit the numbers that make up the
bytes you want to search for, like :
D3 45 FF 00 C4 6E
There is no need to enter a space between each byte as
I do that for you while you're entering your bytes.
For a text sequence, just type in the text to search
for, no quotes are needed, and hit Enter. The maximum
length for a text sequence is 25 characters. And a
change from my earlier versions, the search is now case
insensitive.
If the search string is found, the display will move to
that string's location in the file and will be high-
lighted at the top of the screen. You can now hit any
key to continue the search, hit 'M' to Mark the
position or hit ESC to stop searching.
Just to make things simple for myself, every search
starts at the beginning of the file. Even on large
files, starting at the beginning to find something you
know is near the end doesn't take very long at all (at
least not on my 16 Mhz 386sx!)
■-- Z : Clear all entries from marker stack
This command will delete all entries from the marker
stack. Careful, there is no turning back from the
results of this command.
≡■≡ Comments
I would strongly suggest that you make a backup copy of the
file you're going to modify, just in case you decide later
you want the original file back. You should have a backup copy
anyway as a matter of safeguarding your files in case of
catastrophe.
I have a 16Mhz 386sx AT running MS-DOS 5.0. XE should work
with most system configurations though. It does not support
any video modes other than 80x25 text and will work with a
monochrome monitor.
Also, I don't expect any payment for use of this program. Feel
FREE to use it how you like, but be careful :).
I would like to hear any comments or complaints you might
have about this program. I can be reached on GEnie under
R.STUNTZ, or on The Chicago Megaphile BBS (312 283-4035) under
ROB STUNTZ. Or if you prefer, the good ole' U.S. Postal
Service.
Rob
≡■≡ Version History
v1.0 4-8-91 - Initial writing
v1.1 5-16-91 - Minor internal changes
v1.2 7-4-91 - added Marker commands
v1.21 8-3-91 - increased marker stack size to 100
added Z command; clear marker stack
v1.3 8-12-91 - added Goto Offset command
fixed a bug or two
v2.0 9-25-91 - added Loadfile box (instead of typing in
the filename)
set to video page 0 at startup
(this was done in case you shell out from
another program and that program puts you
in a video page other than 0, like Turbo
Debugger. XE needs to be in video page
0. XE returns to the video page you
where at before it started when you exit)
added backspace key use while editing (acts
like left arrow key)
added 'D', 'H' and 'O' commands while viewing
changed Help command to 'F1' from 'H'
made Search command case insensitive
added ability to enter a drive designator
on cmd line to start Loadfile box on that drive
and of course fixed some bugs ...
v2.1 10-19-91 - decided I better try and trap most of the
I/O, as opposed to only some, for errors,
to avoid a possible run-time error
allow loading of read-only files
allow entry of ASCII chars 32-255 when
editing in ASCII portion of display
(formerly 32-126)
check for and handle extremely long path names
in display
swapped ability to change Help screen color
with Base convert
search command now highlights found text,
(no flashing arrow!)
hidden files (and directories) are lowercase
in Loadfile box
and the usual bug fixes ...
v2.11 10-21-91- fixed base convert color saving and loading
from cfg file
v3.0 11-11-91- fixed pagedown problem of going past EOF on
display for files with a length approaching
that of the buffer size.
added '%' into file indicator
you can now call up the ascii chart and
base convert from edit mode with
Alt+A, Alt+B
in edit mode, Pg Up/Dn now just goto first/
last line. column position is not changed.
totally new help system (yea!)
≡■≡
'Turbo Pascal' and 'Turbo Debugger' are registered trademarks
of Borland International, Inc.